package com.xiaochong.bitong.api.controller;

import com.xc.logclient.utils.LogTrace;
import com.xiaochong.bitong.api.constant.HttpHeaderCons;
import com.xiaochong.bitong.api.service.CoinAndPairSearchService;
import com.xiaochong.bitong.api.utils.ApiVersion;
import com.xiaochong.bitong.api.utils.RequestUtil;
import com.xiaochong.tir.common.data.mapperSearchResult.ExchangeTransactionpair;
import com.xiaochong.tir.common.data.po.CurrencyInfo;
import com.xiaochong.tir.common.data.vo.ApiResultVo;
import com.xiaochong.tir.common.data.vo.currencySeaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description: 币种和交易对搜索
 * @Author: org
 * @CreateDate: 2018/8/9 17:43
 */
@Api(value = "搜索")
@RequestMapping(value = ApiVersion.API_V1_PREFIX+"/search")
@RestController
public class CoinAndPairSearchController {

    @Autowired
    private CoinAndPairSearchService coinAndPairSearchService;

    /**
     * 货币搜索
     */
    @ApiOperation(value = "货币搜索" , notes = "货币搜索（参数coinNameCn）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页数（默认1）", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数（默认30）", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "searchText", value = "搜索内容", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "token", value = "用户token", required = false, dataType = "String", paramType = "query")
    })
    @PostMapping("currencySea")
    public ApiResultVo<List<currencySeaVo>> currencySea(@RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                                        @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                        @RequestParam(value = "searchText", required = true) String searchText,
                                                        @RequestParam(value = "token", required = false) String token
                                                        ){
        ApiResultVo api=coinAndPairSearchService.currencySea(pageIndex,pageSize,searchText,token);
        return api;
    }
    @ApiOperation(value = "热门货币" , notes = "热门货币")
    @PostMapping("currencyMarketSea")
    public ApiResultVo<List<currencySeaVo>> currencyMarketSea(){
        ApiResultVo api=coinAndPairSearchService.currencyMarketSea();
        return api;
    }
    @ApiOperation(value = "交易对搜索" , notes = "货币搜索（参数coinNameCn）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页数（默认1）", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数（默认30）", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "searchText", value = "搜索内容", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "token", value = "用户token", required = false, dataType = "String", paramType = "query")
    })
    @PostMapping("pairSea")
    public ApiResultVo<List<ExchangeTransactionpair>> pairSea(@RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                                              @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                              @RequestParam(value = "searchText", required = true) String searchText,
                                                              @RequestParam(value = "token", required = false) String token){
        ApiResultVo api=coinAndPairSearchService.pairSea(pageIndex,pageSize,searchText,token);
        return api;
    }
}
